import { createRouter, createWebHistory } from "vue-router"

import Login from "../components/Login.vue"
import Main from "../components/Main.vue"

import Producer from "../components/Home/Producer/Producer.vue"
import Broker from "../components/Home/Broker/Broker.vue"
import Supermarket from "../components/Home/Supermarket/Supermarket.vue"
import Consumer from "../components/Home/Consumer/Consumer.vue"

const router = createRouter({
    history: createWebHistory("/ShiLianZhiKong/"), // 路由器工作模式
    routes: [ // 路由规则
        {
            path: "/",
            redirect: "/login"
        },
        {
            path: "/home",
            redirect: "/login"
        },
        {
            path: "/login",
            name: "登录",
            component: Login
        },
        {
            path: "/home",
            component: Main,
            children: [
                {
                    path: "producer",
                    name: "生产者",
                    component: Producer
                },
                {
                    path: "broker",
                    name: "中间商",
                    component: Broker
                },
                {
                    path: "supermarket",
                    name: "超市",
                    component: Supermarket
                },
                {
                    path: "consumer",
                    name: "消费者",
                    component: Consumer
                }
            ]
        },
    ]
})
export default router // 暴露组件